@inherits MiniRazor.TemplateBase<CodeModule>
@namespace OSharp.CodeGeneration.Templates
@using System;
@using System.Linq;
@using OSharp.CodeGeneration.Services.Entities
@using OSharp.CodeGeneration.Utils
@using OSharp.Collections;
@using OSharp.Exceptions;
@using OSharp.Extensions;
@{
  CodeModule module = Model;
  string lowerModule = module.Name.ToLowerCase();
  string urlModule = module.Name.UpperToLowerAndSplit();
}// -----------------------------------------------------------------------
//  <once-generated>
//     这个文件只生成一次，再次生成不会被覆盖。
//  </once-generated>
//
//  <copyright file="src/router/routes/modules/@(module.Name.UpperToLowerAndSplit()).ts" company="@module.Project.Company">
//      @module.Project.Copyright
//  </copyright>
//  <site>@module.Project.SiteUrl</site>
//  <last-editor>@module.Project.Creator</last-editor>
// -----------------------------------------------------------------------
import type { AppRouteModule } from '/@@/router/types';
import { LAYOUT } from '/@@/router/constant';
import { t } from '/@@/hooks/web/useI18n';

const @(lowerModule): AppRouteModule = {
  path: '/@(lowerModule)',
  name: '@(module.Name)',
  component: LAYOUT,
  redirect: '/@(lowerModule)/@(module.Entities.FirstOrDefault()?.Name.UpperToLowerAndSplit())',
  meta: {
    icon: '@(module.Icon)',
    title: t('routes.@(lowerModule).@(lowerModule)'),
  },
  children: [
@foreach (var entity in module.Entities)
{
  string urlEntity = entity.Name.UpperToLowerAndSplit();
  string lowerEntity = entity.Name.ToLowerCase();
<text>    {
      path: '@(urlEntity)',
      name: '@(entity.Name)',
      component: () => import('/@@/views/@(lowerModule)/@(lowerEntity)/index.vue'),
      meta: {
        icon: '@(entity.Icon)',
        title: t('routes.@(lowerModule).@(lowerEntity)'),
      },
    },
</text>
}
  ],
};

export default @(lowerModule);

